<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class IndexController extends Controller
{
    //前台首页
    public function getIndex()
    {
        //轮播图
        $min = DB::table('tcarousel')->min('id');
        $one = DB::table('tcarousel')->where('id',$min)->first();
        $data = DB::table('tcarousel')->get();
        //网站配置
        $config = DB::table('config')->first();
        //选项卡
        $mins = DB::table('inmod')->min('id');
        $tabw = DB::table('inmod')->where('pid',$mins)->get();
        $tabs = DB::table('inmod')->get();
        $datas = DB::table('inmod')->where('pid',0)->get();
        //捐赠
        $loveuser = DB::table('loveuser')->get();
        //下载 微博 微信
        $down = DB::table('down')->get();
        //解析模板
        return view('Home.index',['data'=>$data,'config'=>$config,'one'=>$one,'datas'=>$datas,'tabs'=>$tabs,'tabw'=>$tabw,'loveuser'=>$loveuser,'down'=>$down]);
    }

    //选项卡文章内容
    public function getContent($id)
    {
        $config = DB::table('config')->first();
        $data = DB::table('tabcontent')->where('tid',$id)->first();
        if(empty($data)){
          return back();
        }
        return view('Home.content.tab',['data'=>$data,'config'=>$config]);
    }

    //轮播图文章内容
    public function getTcacontent($id)
    {
        $config = DB::table('config')->first();
        $data = DB::table('tcarousel')->where('pid',$id)->first();
        if(empty($data)){
          return back();
        }
        return view('Home.content.tab',['data'=>$data,'config'=>$config]);
    }
}
